<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>xeokit Example</title>
    <link href="../css/pageStyle.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>
</head>
<body>
<input type="checkbox" id="info-button"/>
<label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label>
<canvas id="myCanvas"></canvas>
<div class="slideout-sidebar">
    <h1>LambertMaterial</h1>
    <p>A non-physically-correct flat-shading material.</p>
    <h3>Components used</h3>
    <ul>
        <li>
            <a href="../../docs/class/src/viewer/Viewer.js~Viewer.html"
               target="_other">Viewer</a>
        </li>
        <li>
            <a href="../../docs/class/src/viewer/scene/mesh/Mesh.js~Mesh.html"
               target="_other">Mesh</a>
        </li>
        <li>
            <a href="../../docs/class/src/viewer/scene/geometry/ReadableGeometry.js~ReadableGeometry.html"
               target="_other">ReadableGeometry</a>
        </li>
        <li>
            <a href="../../docs/function/index.html#static-function-buildTorusGeometry"
               target="_other">buildTorusGeometry()</a>
        </li>
        <li>
            <a href="../../docs/class/src/viewer/scene/materials/LambertMaterial.js~LambertMaterial.html"
               target="_other">LambertMaterial</a>
        </li>
        <li>
            <a href="https://github.com/xeokit/xeokit-sdk/wiki/Material-Workflows" target="_other">User Guide</a>
        </li>

    </ul>
</div>
</body>

<script id="source" type="module">

    //------------------------------------------------------------------------------------------------------------------
    // Import the modules we need for this example
    //------------------------------------------------------------------------------------------------------------------

    import {Viewer, Mesh, buildTorusGeometry, ReadableGeometry, LambertMaterial} from "../../dist/xeokit-sdk.min.es.js";

    //------------------------------------------------------------------------------------------------------------------
    // Create a Viewer and arrange the camera
    //------------------------------------------------------------------------------------------------------------------

    const viewer = new Viewer({
        canvasId: "myCanvas"
    });

    viewer.scene.camera.eye = [0, 0, 5];
    viewer.scene.camera.look = [0, 0, 0];
    viewer.scene.camera.up = [0, 1, 0];

    //------------------------------------------------------------------------------------------------------------------
    // Create a mesh with torus shape and LambertMaterial
    //------------------------------------------------------------------------------------------------------------------

    new Mesh(viewer.scene, {
        geometry: new ReadableGeometry(viewer.scene, buildTorusGeometry({
            center: [0, 0, 0],
            radius: 1.5,
            tube: 0.5,
            radialSegments: 12,
            tubeSegments: 8,
            arc: Math.PI * 2.0
        })),
        material: new LambertMaterial(viewer.scene, {
            ambient: [0.3, 0.3, 0.3],
            color: [0.5, 0.5, 0.0],
            alpha: 1.0, // Default
            lineWidth: 1,
            pointSize: 1,
            backfaces: false,
            frontFace: "ccw"
        })
    });

</script>
</html>